package com.mmp.main.entity;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * The persistent class for the sys_role database table.
 *
 */
@Entity
@Table(name = "sys_role")
@NamedQuery(name = "SysRole.findAll", query = "SELECT s FROM SysRole s")
public class SysRole implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	private Integer id;

	private String description;

	private String dest_URL;

	@Column(name = "display_name")
	private String displayName;

	@Column(name = "display_order")
	private Integer displayOrder;

	@Column(name = "menu_name")
	private String menuName;

	// bi-directional many-to-one association to SysRoleGroup
	@ManyToOne
	@JoinColumn(name = "group_id")
	private SysRoleGroup sysRoleGroup;

	// bi-directional many-to-many association to User
	@ManyToMany(mappedBy = "sysRoles")
	private List<User> users;

	// bi-directional many-to-one association to UserRole
	@OneToMany(mappedBy = "sysRole")
	private List<UserRole> userRoles;

	public SysRole() {
	}

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getDest_URL() {
		return this.dest_URL;
	}

	public void setDest_URL(String dest_URL) {
		this.dest_URL = dest_URL;
	}

	public String getDisplayName() {
		return this.displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

	public Integer getDisplayOrder() {
		return this.displayOrder;
	}

	public void setDisplayOrder(Integer displayOrder) {
		this.displayOrder = displayOrder;
	}

	public String getMenuName() {
		return this.menuName;
	}

	public void setMenuName(String menuName) {
		this.menuName = menuName;
	}

	public SysRoleGroup getSysRoleGroup() {
		return this.sysRoleGroup;
	}

	public void setSysRoleGroup(SysRoleGroup sysRoleGroup) {
		this.sysRoleGroup = sysRoleGroup;
	}

	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public List<UserRole> getUserRoles() {
		return this.userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

	public UserRole addUserRole(UserRole userRole) {
		getUserRoles().add(userRole);
		userRole.setSysRole(this);

		return userRole;
	}

	public UserRole removeUserRole(UserRole userRole) {
		getUserRoles().remove(userRole);
		userRole.setSysRole(null);

		return userRole;
	}

}
